Install Docular

Now that you have NodeJS, NPM, and Grunt installed, it's time to install the grunt-docular package.

The grunt-docular package will bring in Docular as a dependency and exposes tasks that hook into the Docular package.

Install the grunt-docular package

  1. Navigate to the root of your project
    cd <your project root>
    
  2. Install the grunt-docular plugin
    npm install grunt-docular
    
  3. Add this line to the Gruntfile.js file to include the grunt-docular tasks
    grunt.loadNpmTasks('grunt-docular');
    
  4. Add the basic configuration to the initConfigs for the docular task
    docular: {
        groups: [],
        showDocularDocs: true,
        showAngularDocs: true
    }
    
  5. Register a default task for convenience by adding this line to the Gruntfile.js file
    grunt.registerTask('default', ['docular']);
    

The final Gruntfile.js with mods should look like this:

module.exports = function(grunt) {

    // Project configuration.
    grunt.initConfig({

        pkg: grunt.file.readJSON('package.json'),

        docular: {
            groups: [],
            showDocularDocs: true,
            showAngularDocs: true
        }

    });

    // Load the plugin that provides the "docular" tasks.
    grunt.loadNpmTasks('grunt-docular');

    // Default task(s).
    grunt.registerTask('default', ['docular']);

};

Note that we have enabled the inclusion of the AngularJS docs and Docular docs as an example to make sure everything is working. You can turn them off later when you have created your own "groups".

Test your grunt-docular install and configuration

  1. From the root of your project run the default grunt task
    grunt
    
  2. You should see some successful console statments, something similar to this:
    Running "docular" task
    
    -------- generating documentation objects --------
    Extracting docular Documentation For Section "docularinstall"...
    Extracting docular Documentation For Section "docularoverview"...
    Extracting docular Documentation For Section "docularext"...
    Extracting docular Documentation For Section "docular"...
    Extracting angular Documentation For Section "api"...
    Extracting angular Documentation For Section "guide"...
    Extracting angular Documentation For Section "tutorial"...
    Extracting angular Documentation For Section "misc"...
    -------- generating partials directories for groups --------
    -------- generating partials directories for sections --------
    -------- merging child docs with parents --------
    BAD LINK: documentation/angular/cookbook/index
    -------- generating partials --------
    -------- generating keyword data --------
    -------- generating index.html page --------
    -------- ordering and concatenating doc_api css and js --------
    -------- generating report --------
    DONE! Generated 229 pages in 2964 ms. Partials per second : 77
    
  3. Now you can spin up a NodeJS server to view your documentation by running the docular-server task
    grunt docular-server
    
  4. Verify the succesful console statment for the server
    Documentation server running at http://127.0.0.1:8000/
    
  5. Navigate your browser to the specified URL and view Docular docs